#!python

from kinect import *
import numpy as np
import pylab as plt


def display(data):
	plt.imshow(data, interpolation='nearest', animated=True)

def color_data_factory(buffer):
    """
    Converts pointers to numpy data
    """
    data = np.array(buffer)
    data.resize((480, 640, 3))
    return data
	
def depth_data_factory(buffer):
    """
    Converts pointers to numpy data
    """
    data = np.array(buffer)
    data.resize((480, 640))
    return data

lin = MinimalListener()
kf = KinectFinder()
kin = kf.GetKinect()
kin.AddListener(lin)

kin.SetMotorPosition(1)

plt.figure(1)
display(color_data_factory(kin.mColorBuffer))
plt.figure(2)
display(depth_data_factory(kin.mDepthBuffer))
plt.show()
